﻿using System;

namespace Fast.Extensions.RabbitMQ
{
    [SkipScan]
    public class BasicConsumeContext
    {
        /// <summary>
        /// 交换机
        /// </summary>
        public ExchangeDeclareConfiguration Exchange { get; set; }

        /// <summary>
        /// 队列
        /// </summary>
        public QueueDeclareConfiguration Queue { get; set; }

        /// <summary>
        /// 连接名
        /// </summary>
        public string ConnectionName { get; set; }

        /// <summary>
        /// 路由Key
        /// </summary>
        public string RoutingKey { get; set; }

        /// <summary>
        /// 是否启动死信交换
        /// </summary>
        public bool EnableDeadLetterExchange { get; set; }

        /// <summary>
        /// 消息类型
        /// </summary>
        public MessageType MessageType { get; set; }

        /// <summary>
        /// 
        /// </summary>
        /// <param name="exchange"></param>
        /// <param name="queue"></param>
        /// <param name="connectionName"></param>
        /// <param name="routingKey"></param>
        /// <param name="enableDeadLetterExchange"></param>
        /// <param name="messageType"></param>
        public BasicConsumeContext(ExchangeDeclareConfiguration exchange, QueueDeclareConfiguration queue, string connectionName,
            string routingKey, bool enableDeadLetterExchange, MessageType messageType)
        {
            Exchange = exchange ?? throw new ArgumentNullException(nameof(exchange));
            Queue = queue ?? throw new ArgumentNullException(nameof(queue));
            ConnectionName = connectionName;
            RoutingKey = routingKey;
            EnableDeadLetterExchange = enableDeadLetterExchange;
            MessageType = messageType;

            if (string.IsNullOrWhiteSpace(Queue.QueueName))
            {
                throw new ArgumentNullException(nameof(Queue.QueueName));
            }
        }
    }
}
